"""
This example demonstrates how to use a specific ONNX execution provider with Kokoro.

For available providers, see:
https://github.com/microsoft/onnxruntime/issues/22101#issuecomment-2357667377

Setup:
1. Install dependencies: pip install kokoro-onnx soundfile
2. Download model and voices:
   wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/kokoro-v1.0.onnx
   wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/voices-v1.0.bin

Run:
macOS/Linux: ONNX_PROVIDER="CPUExecutionProvider" python examples/with_provider.py
Windows PowerShell: $env:ONNX_PROVIDER="CPUExecutionProvider" ; python examples/with_provider.py
"""

import soundfile as sf
from kokoro_onnx import Kokoro

kokoro = Kokoro("kokoro-v1.0.onnx", "voices-v1.0.bin")
samples, sample_rate = kokoro.create(
    "Hello. This audio generated by kokoro!", voice="af_sarah", speed=1.0, lang="en-us"
)
sf.write("audio.wav", samples, sample_rate)
print("Created audio.wav")
